package com.aaa.vegetablemarketexpress.dao;

import com.aaa.vegetablemarketexpress.entity.Shop;
import com.aaa.vegetablemarketexpress.entity.ShopAuditStatusCount;
import com.aaa.vegetablemarketexpress.entity.ShopStatusCount;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * @FileName: ShopDao
 * @Description: 店铺数据访问层接口
 * @Author: qxh
 * @CreateTime: 2025/9/10
 * @Version: 1.0.0
 */
@Mapper
public interface ShopDao {
    /**
     * 根据店铺ID查询店铺信息
     * @param shopId
     * @return
     */
    Shop selectShopById(Long shopId);

    /**
     * 分页查询店铺列表,显示所有
     * @param shop
     * @return
     */
    List<Shop> selectShopList(Shop shop);

    /**
     * 分页查询店铺列表,关联商家、关联客户
     * @param  userId
     * @return
     */
    List<Shop> selectShopListBindCustomer(Long userId);
    /**
     * 添加店铺
     * @param shop
     * @return
     */
    int insertShop(Shop shop);

    /**
     * 修改店铺
     * @param shop
     * @return
     */
    int updateShop(Shop shop);

    /**
     * 删除店铺（逻辑删除）
     * @param shopId
     * @return
     */
    int deleteShopById(Long shopId);

    /**
     * 检查店铺名称是否唯一
     * @param shopName
     * @return
     */
    int checkShopNameUnique(String shopName);
    /**
     * 根据用户ID查询客户ID
     * @param userId
     * @return
     */
    Long queryCustomerIdByUserId(Long userId);

    /**
     * 店铺审核成功
     * @param shop
     * @return
     */
    List<Shop> selectShopListAuditStatus(Shop shop);
    // 查询所有店铺信息
    List<Shop> findAllShops();
    // 统计不同状态的店铺数量
    @Select("SELECT status, COUNT(*) as count FROM biz_shop GROUP BY status")
    List<ShopStatusCount> countShopsByStatus();
    // 统计不同审核状态的店铺数量
    @Select("SELECT audit_status, COUNT(*) as count FROM biz_shop GROUP BY audit_status")
    List<ShopAuditStatusCount> countShopsByAuditStatus();
    Long countShops();
}
